# Contributor: psykose <alice@ayaya.dev>
# Maintainer: psykose <alice@ayaya.dev>
pkgname=libcgroup
pkgver=2.0.2
pkgrel=0
pkgdesc="cgroup library"
url="https://github.com/libcgroup/libcgroup"
arch="all"
license="LGPL-2.1-only"
makedepends="
	bsd-compat-headers
	byacc
	flex
	fts-dev
	libtool
	linux-headers
	linux-pam-dev
	"
subpackages="$pkgname-doc $pkgname-static $pkgname-pam $pkgname-dev cgroup-tools:_tools"
source="https://github.com/libcgroup/libcgroup/releases/download/v$pkgver/libcgroup-$pkgver.tar.gz"
# tests seem to fail for no reason and prompt sudo
# cgexec suid
options="!check suid"

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--enable-pam-module-dir=/lib/security
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	# the .so is the one that is used
	rm "$pkgdir"/lib/security/pam_cgroup.a
}

pam() {
	pkgdesc="$pkgdesc (pam module)"
	amove lib/security
}

_tools() {
	pkgdesc="$pkgdesc (tools)"
	amove usr/bin usr/sbin
}

sha512sums="
824d4408bcd1e2848358c57ed02cdf5ccf1e20a3963dac26e15140985da3d88ced7d583e0c6108ad1b11729ee608f0018e3726fb59211f2e04417fd3e4fd1c9f  libcgroup-2.0.2.tar.gz
"
